$OpenBSD: patch-uulib_uulib_c,v 1.1.1.1 2014/11/20 21:14:54 jca Exp $

- renaming file, if it's on the same filesystem, instead of copying
- fix problem with long headers, patch from Debian, but originally from
  http://nget.sourceforge.net/Changelog.html and
  http://nget.sf.net/patches/uulib-0.5.19-uuinfofile-long-headers.patch

--- uulib/uulib.c.orig	Tue Sep 30 01:27:47 2003
+++ uulib/uulib.c	Mon Jan 27 21:44:47 2014
@@ -872,7 +872,10 @@ UUDecodeToTemp (uulist *thefile)
 }
 
 /*
- * decode file first to temp file, then copy it to a final location
+ * Decode file first to temp file, then copy it to a final location.
+ * A move is preferable to a copy.  If the file is on the same
+ * partition, no copy is performed.  This is important for large
+ * files.
  */
 
 int UUEXPORT
@@ -978,6 +981,12 @@ UUDecodeFile (uulist *thefile, char *destname)
     return UURET_IOERR;
   }
 
+  if (rename(thefile->binfile, uugen_fnbuffer) == 0) {
+    fclose(source);
+    close(fildes);
+    goto finish_ok;
+  }
+
   if ((target = fdopen (fildes, "wb")) == NULL) {
     progress.action = 0;
     UUMessage (uulib_id, __LINE__, UUMSG_ERROR,
@@ -1042,6 +1051,8 @@ UUDecodeFile (uulist *thefile, char *destname)
 	       thefile->binfile,
 	       strerror (uu_errno = errno));
   }
+
+ finish_ok:
   _FP_free (thefile->binfile);
   thefile->binfile = NULL;
   thefile->state  &= ~UUFILE_TMPFILE;
@@ -1103,9 +1114,9 @@ UUInfoFile (uulist *thefile, void *opaque,
 
   while (!feof (inpfile) && 
 	 (uu_fast_scanning || ftell(inpfile) < maxpos)) {
-    if (_FP_fgets (uugen_inbuffer, 511, inpfile) == NULL)
+    if (_FP_fgets (uugen_inbuffer, 1023, inpfile) == NULL)
       break;
-    uugen_inbuffer[511] = '\0';
+    uugen_inbuffer[1023] = '\0';
 
     if (ferror (inpfile))
       break;
